import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { InfoCircleOutlined } from '@ant-design/icons';
import { ConfigProvider, Tooltip } from 'antd-v4';
import classNames from 'classnames';
import React, { useContext } from 'react';
import './index.less';
/**
 * 在 form 的 label 后面增加一个 tips 来展示一些说明文案
 *
 * @param props
 */

var LabelIconTip = function LabelIconTip(props) {
  var label = props.label,
      tooltip = props.tooltip,
      ellipsis = props.ellipsis,
      subTitle = props.subTitle;

  var _useContext = useContext(ConfigProvider.ConfigContext),
      getPrefixCls = _useContext.getPrefixCls;

  if (!tooltip && !subTitle) {
    return _jsx(_Fragment, {
      children: label
    });
  }

  var className = getPrefixCls('pro-core-label-tip');
  var tooltipProps = typeof tooltip === 'string' || /*#__PURE__*/React.isValidElement(tooltip) ? {
    title: tooltip
  } : tooltip;

  var icon = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.icon) || _jsx(InfoCircleOutlined, {});

  return _jsxs("div", {
    className: className,
    onMouseDown: function onMouseDown(e) {
      return e.stopPropagation();
    },
    onMouseLeave: function onMouseLeave(e) {
      return e.stopPropagation();
    },
    onMouseMove: function onMouseMove(e) {
      return e.stopPropagation();
    },
    children: [_jsx("div", {
      className: classNames("".concat(className, "-title"), _defineProperty({}, "".concat(className, "-title-ellipsis"), ellipsis)),
      children: label
    }), subTitle && _jsx("div", {
      className: "".concat(className, "-subtitle"),
      children: subTitle
    }), tooltip && _jsx(Tooltip, _objectSpread(_objectSpread({}, tooltipProps), {}, {
      children: _jsx("span", {
        className: "".concat(className, "-icon"),
        children: icon
      })
    }))]
  });
};

export default /*#__PURE__*/React.memo(LabelIconTip);